package com.cztv.vote.schedule;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.cztv.pub.cache.CacheManager;
import com.cztv.vote.bean.VoteProjectBean;
import com.cztv.vote.service.VoteManager;

public class CacheInitJob {
	private static Log logger = LogFactory.getLog(CacheInitJob.class); 
	private   VoteManager voteManager;
	public void setVoteManager(VoteManager voteManager) {
		this.voteManager = voteManager;
	}
	
	public void init(){
		List<VoteProjectBean> list=voteManager.queryAllProjects();
		
		logger.info("初始化投票项目保存到内存...");
		for(VoteProjectBean bean:list){
			CacheManager.getInstance().putContent(String.valueOf(bean.getPid()), bean, 60000);
		}
		logger.info("缓存初始化完成");
		
		System.out.println(CacheManager.getInstance().getCacheSize());
		
	}
}
